from plot import Plots
import tushare as ts
from gupiao import autoOrder
from cls.orm.main import PG
from cls.finance.stock import Share


codes = ['000001', '000002', '000004', '000005', '000006', '000007', '000008', '000009', '000010', '000011']
share = Share('000002')
# print(share.dayVS('20181214'))
rmb = share.testSystem('20150101', '20181217')

# res = share.today5vs20()
# print('000001' + '-----' + res)
# for code in codes:

exit(2)


pgObj = PG()
pgEngine = pgObj.engine()

code = '600926'
pro = ts.pro_api('4552d85ac2d1492fc488a32646b501ed6faf1835820f65408790e59d')
data = pro.query('stock_basic', exchange='', list_status='L', fields='ts_code,symbol')

print(data.index)
print(len(data.values))
exit(9)
for row in data.loc[350:].values:
    try:
        df = pro.daily(ts_code=row[0], start_date='20050101', end_date='20181216');
    except IOError:
        print("Error: 获取数据失败：" + row[1])
    else:
        print('获取数据成功:' + row[1])
        try:
            df.to_sql(row[1], pgEngine, index=False, if_exists='fail', schema='gegu')
        except :
            print('Error:存在表:' + row[1])
        else:
            print('数据插入成功:' + row[1])


# df = gp.getDay('20181001', '20181201')


# print(df.columns)
# exit(9)
# pullDF = df[['open', 'high', 'low', 'close', 'trade_date']]
# gp.plotDF(df)


# engine = create_engine('postgresql://postgres:123456@localhost:5433/stock')


